<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>手术室执行详情</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
  <style>
    /* 穿梭框样式开始 */
    #shuttle_box {
      /* width: 1000px; */
      zoom: 1;
      margin: 30px auto;
    }

    #shuttle_box:after {
      content: ".";
      clear: both;
      display: block;
      height: 0;
      overflow: hidden;
      visibility: hidden;
    }

    .shuttle_box_li {
      height: 540px;
      float: left;
    }

    .shuttle_box_near {
      width: 300px;
      background-color: #ffffff;
      overflow-y: scroll;
      overflow-x: hidden;
      border-radius: 10px;
    }

    .shuttle_box_li_act {
      color: #ffffff !important;
      background-color: #009688 !important;
      border-bottom: 1px solid #ffffff;
      transition: all .01s;
    }

    .shuttle_box_near::-webkit-scrollbar {
      /*滚动条整体样式*/
      width: 6px;
      /*高宽分别对应横竖滚动条的尺寸*/
      height: 1px;
    }

    .shuttle_box_near::-webkit-scrollbar-thumb {
      /*滚动条里面小方块*/
      border-radius: 20px;
      background-color: rgba(0, 0, 0, 0.5);
    }

    .shuttle_box_near::-webkit-scrollbar-track {
      /*滚动条里面轨道*/
      background-color: rgba(0, 0, 0, 0.2);
      border-radius: 20px;
    }

    .shuttle_box_near li {
      padding: 8px;
      border-bottom: 1px solid #ffffff;
      background-color: #f4f4f4;
      cursor: pointer;
      transition: all .5s;
    }

    .shuttle_box_li_act:hover {
      opacity: 0.7;
      transition: all .01s;
    }

    #shuttle_box_mid {
      /* width: 80px; */
      text-align: center;
    }

    #shuttle_box_mid button {
      width: 50px;
      height: 30px;
      display: block;
      margin: 20px auto;
      line-height: 30px;
      color: white;
      cursor: pointer;
      background-color: #009688;
      border-radius: 5px;
      transition: all .5s;
      border: none;
    }

    #shuttle_box_mid button:hover {
      opacity: 0.7;
      transition: all .5s;
    }

    #shuttle_box_toRight {
      margin-top: 225px !important;
    }

    .shuttle_box_left_title {
      top: -15px;

    }

    /* 穿梭框样式结束 */
  </style>
</head>

<body>
  <div class="layui-fluid" id="LAY-component-grid-list">
    <div class="layui-row layui-col-space10 demo-list">
      <div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
        <!-- 具体某个手术室的预约详情 -->
        <div class="layui-card">
          <div class="layui-card-header">查询</div>
          <div class="layui-card-body" id="search-view">
            <!-- 填充查询模板 -->
          </div>
        </div>
        <div class="layui-card">
          <div class="layui-card-header">预约信息</div>
          <div class="layui-card-body">
            <!-- 预约信息的表格 -->
            <table id="bookings-table" lay-filter="bookingsTable">
            </table>
          </div>
        </div>
      </div>

    </div>
  </div>

  <script src="../../layuiadmin/layui/layui.js" charset="utf-8"></script>
  <!-- <script src="../../../js/axios.min.js"></script>
  <script src="../../../js/vue.js"></script> -->


  <!-- 查询表单开始 -->
  <script id="demo" type="text/html">
    <form class="layui-form" action="" id="searchForm">
      <div class="layui-inline" id="surgeryrooms">
        <div class="layui-form-item">
          <label class="layui-form-label">选择手术室</label>
          <div class="layui-input-inline">
            <select name="surgeryRoomId" lay-filter="surgeryRoomId">
              <option value="">请选择手术室</option>
              {{#  layui.each(d.data, function(index, item){ }}
              <option value="{{item.surgeryRoomId}}">{{item.surgeryRoomName}}</option>
              {{#  }); }}
            </select>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">患者</label>
            <div class="layui-input-inline">
              <input type="text" name="inpatientName" autocomplete="off" value="" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">主刀医生</label>
            <div class="layui-input-inline">
              <input type="text" name="empDocId" autocomplete="off" value="" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">责任护士</label>
            <div class="layui-input-inline">
              <input type="text" name="empNurId" autocomplete="off" value="" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
              <input type="text" name="startTime" autocomplete="off" value="" class="layui-input" id="search-startTime">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
              <input type="text" name="endTime" autocomplete="off" value="" class="layui-input" id="search-endTime">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
              <button type="submit" class="layui-btn layui-icon layui-icon-search" lay-submit=""
                lay-filter="search">查询</button>
              <button type="reset" class="layui-btn layui-btn-warm layui-icon layui-icon-refresh">重置</button>
            </div>
          </div>
        </div>
    </form>
  </script>
  <!-- 查询表单模板 -->

  <!-- 手术室模板开始 -->
  <script id="surgery" type="text/html">
    <label class="layui-form-label">选择手术室</label>
    <div class="layui-input-inline">
      <select name="surgeryRoomId" lay-filter="surgeryRoomId">
        <option value="">请选择手术室</option>
        {{#  layui.each(d.data, function(index, item){ }}
        <option value="{{item.surgeryRoomId}}">{{item.surgeryRoomName}}</option>
        {{#  }); }}
      </select>
    </div>
  </script>
  <!-- 手术室模板结束 -->
  <!-- 表格工具条开始 -->
  <div id="table-toolbar" style="display: none" lay-filter="tableToolbar">
    <button type="submit" class="layui-btn layui-icon layui-icon-add-1" lay-event="addBooking">添加</button>
    <!-- <button type="reset" class="layui-btn layui-btn-primary" lay-event="batchDelete">批量删除</button> -->
  </div>
  <!-- 表格工具条结束 -->
  <!-- 行工具开始 -->
  <script type="text/html" id="row-bar">
    <a class="layui-btn layui-btn-xs layui-icon layui-icon-edit" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs layui-icon layui-icon-group" lay-event="emparr">人员安排</a>
  </script>
  <!-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> -->
  <!-- 行工具结束 -->

  <!-- 添加修改 弹出层开始 -->
  <div style="display: none;" id="addOrEditDiv">
    <form id="dataForm" lay-filter="dataForm" class="layui-form" style="padding: 20px" action="">
      <input type="hidden" name="surgeryExeId">
      <input type="hidden" name="bookingId">
      <div class="layui-form-item" id="chooseSurgeryRoom">
        <!-- 渲染手术室列表 -->
      </div>
      <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label">患者</label>
          <div class="layui-input-inline">
            <input type="text" name="inpatientId" autocomplete="off" class="layui-input" lay-verify="required">
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label">主刀医生</label>
          <div class="layui-input-inline">
            <input type="text" name="empDocId" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">责任护士</label>
          <div class="layui-input-inline">
            <input type="text" name="empNurId" autocomplete="off" class="layui-input">
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label">开始时间</label>
          <div class="layui-input-inline">
            <input type="text" name="startTime" autocomplete="off" class="layui-input" id="startTime">
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">结束时间</label>
          <div class="layui-input-inline">
            <input type="text" name="endTime" autocomplete="off" class="layui-input" id="endTime">
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-block">
          <label class="layui-form-label">过程描述</label>
          <div class="layui-input-block">
            <textarea name="describ" placeholder="请输入内容" class="layui-textarea"></textarea>
            <!-- style="display: none;" id="exeDescrib" -->
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-block">
          <label class="layui-form-label">是否突发状况</label>
          <div class="layui-input-block">
            <input type="radio" name="status" value="true" title="是">
            <input type="radio" name="status" value="false" title="否">
            <!-- <input type="checkbox" name="status" lay-skin="switch" lay-text="是|否" checked value="false"> -->
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-block">
          <label class="layui-form-label">突发状况描述</label>
          <div class="layui-input-block">
            <textarea name="accidentDesc" placeholder="请输入内容" class="layui-textarea"></textarea>
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-block">
          <label class="layui-form-label">备注</label>
          <div class="layui-input-block">
            <textarea name="note" placeholder="请输入内容" class="layui-textarea"></textarea>
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-block">
          <label class="layui-form-label">手术价格</label>
          <div class="layui-input-block">
            <input type="text" name="surgeryExePrice" placeholder="请输入内容" class="layui-input">
          </div>
        </div>
      </div>
      <div class="layui-form-item" align="center">
        <div class="layui-input-block">
          <button class="layui-btn layui-btn-sm layui-icon layui-icon-release" type="submit" lay-filter="doSubmit"
            lay-submit="">保存</button>
          <button class="layui-btn layui-btn-warm layui-btn-sm layui-icon layui-icon-refresh " type="reset">重置</button>
        </div>
      </div>
    </form>
  </div>
  <!-- 弹出层结束 -->
  <!-- 弹出层 人员添加 穿梭框开始 -->
  <div id="empArrDiv" style="display:none">
    <div class="layui-card">
      <div class="layui-card-header">人员安排</div>
      <div class="layui-card-body " style="background-color: #e8e8e8;">
        <div class="layui-row layui-col-space10 demo-list">
          <div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
            <p>手术编号:<span id="surgeryExeIdForArr"></span></p>
            <ul id="shuttle_box">
              <div class="layui-col-md5">
                <div class="shuttle_box_left_title">选择人员</div>
                <li class="shuttle_box_li shuttle_box_near">

                  <ul id="shuttle_box_left">
                    <!-- 模板渲染后台传的数据 -->
                  </ul>
                </li>
              </div>
              <div class="layui-col-md2">
                <li id="shuttle_box_mid">
                  <select id="surgeryRole">
                    <!-- <option value="">请选择</option>
                    <option value="1">主刀医生</option>
                    <option value="2">辅助医生</option>
                    <option value="3">第二辅助医生</option> -->
                  </select>
                  <button id="shuttle_box_toRight">》》</button>
                  <button id="shuttle_box_toLeft">《《</button>
                </li>
              </div>
              <div class="layui-col-md5">
                <div class="shuttle_box_left_title">具体人员安排</div>
                <li class="shuttle_box_li shuttle_box_near  layui-col-md4">
                  <ul id="shuttle_box_right">

                  </ul>
                </li>
              </div>
            </ul>
          </div>
          <div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
            <div class="layui-form-item" align="center">
              <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm layui-icon layui-icon-release" type="submit"
                  id="surgeryArrSubmit">保存</button>
                <button class="layui-btn layui-btn-warm layui-btn-sm layui-icon layui-icon-refresh "
                  type="reset">重置</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- 弹出层 人员添加 穿梭框结束 -->
  <!-- 人员添加穿梭框中人员信息模板开始 -->
  <script type="text/html" id="emps">
    {{#  layui.each(d.data, function(index, item){ }}
    <li><span data-empId="{{item.empId}}">{{item.empName}}</span></li>
    {{#  }); }}
  </script>
  <!-- 人员添加穿梭框中人员信息模板结束 -->
  <!-- 人员添加穿梭框中手术角色选择框模板开始 -->
  <script type="text/html" id="rolesSelect">
    <option value="">手术中角色</option>
    {{#  layui.each(d.data, function(index, item){ }}
    <option value="{{item.surgeryRoleId}}">{{item.surgeryRoleName}}</option>
    {{#  }); }}
  </script>
  <!-- 人员添加穿梭框中手术角色选择框模板结束 -->
  <!-- 人员添加穿梭框中已有人员安排模板开始 -->
  <script type="text/html" id="surgeryArrs">
    {{#  layui.each(d.data, function(index, item){ }}
      <li class="">
        <span data-arrId="{{item.arrId}}"  data-empid="{{item.emp.empId}}">{{item.emp.empName}}</span><span data-role="{{item.surgeryRoleId}}">&nbsp;&nbsp;|&nbsp;&nbsp;{{item.surgeryRole.surgeryRoleName}}</span>
      </li>
    {{#  }); }}
  </script>
  <!-- 人员添加穿梭框中已有人员安排模板结束 -->
  <script>
    layui.config({
      base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
      index: 'lib/index' //主入口模块
    }).use(['laytpl', 'jquery', 'form', 'element', 'laypage', 'table', 'layer', 'laydate'], function () {
      var laytpl = layui.laytpl;
      var $ = layui.$;
      var form = layui.form;
      var element = layui.element;
      var laypage = layui.laypage;
      var table = layui.table;
      var layer = layui.layer;
      var laydate = layui.laydate;
      var layedit = layui.layedit;
      var data;
      $.post("/surgeryroom/rooms", null, function (resp) {
        console.log(resp);
        if (resp.state == 200) {
          console.log(resp.state)
          // 模板渲染
          data = resp
          var getTpl = demo.innerHTML,
            view = document.getElementById('search-view');
          laytpl(getTpl).render(data, function (html) {
            view.innerHTML = html;
          });
          getTpl = surgery.innerHTML,
            view = document.getElementById('chooseSurgeryRoom');
          laytpl(getTpl).render(data, function (html) {
            view.innerHTML = html;
          });
          // element.render()
          form.render()
        }

      });
      /* form.on('select(surgeryRoomId)', function(data) {
      	alert(data.value);
      			
      }); */
      // 时间选择器
      laydate.render({
        elem: "#search-startTime",
        type: "datetime"
      });
      laydate.render({
        elem: "#search-endTime",
        type: "datetime"
      });
      laydate.render({
        elem: "#endTime",
        type: "datetime"
      });
      laydate.render({
        elem: "#startTime",
        type: "datetime"
      });
      // 富文本编辑器渲染,过程描述，备注，突发状况
      /* var describInx = layedit.build('exeDescrib',{
      	tool: [
      		  'strong' //加粗
      		  ,'italic' //斜体
      		  ,'underline' //下划线
      		  ,'del' //删除线
      		  
      		  ,'|' //分割线
      		  
      		  ,'left' //左对齐
      		  ,'center' //居中对齐
      		  ,'right' //右对齐
      		  ,'link' //超链接
      		  ,'unlink' //清除链接
      		  ]
      }); */

      // 表格渲染
      var tableIns = table.render({
        elem: "#bookings-table",
        url: "/surgeryexe/all",
        method: "post",
        contentType: 'application/json',
        defaultToolbar: [],
        toolbar: "#table-toolbar",
        area: '800px',
        page: true,
        even: true, // 隔行换颜色
        cols: [
          [ // 表头
            {
              type: 'checkbox',
              fixed: 'left'
            }, {
              field: 'surgeryExeId',
              title: 'ID',
              width: 80,
              sort: true,
            }, {
              field: 'bookingId',
              title: '预约ID',
              hide: true
            }, {
              field: 'inpatientId',
              title: '病人id',
              width: 60
            }, {
              field: 'empDocId',
              title: '主刀医生id',
              width: 60
            }, {
              field: 'empNurId',
              title: '责任护士id',
              width: 60
            }, {
              field: 'surgeryRoomId',
              title: '手术室id',
              width: 100,
              sort: true
            }, {
              field: 'surgeryConfirmId',
              hide: true
            }, {
              field: 'startTime',
              title: '开始时间',
              width: 200,
              sort: true
            }, {
              field: 'endTime',
              title: '结束时间',
              width: 200,
              sort: true
            }, {
              field: 'describ',
              title: '描述',
              width: 80,
              sort: true
            }, {
              field: 'status',
              title: '突发状况',
              width: 80,
              sort: true
            }, {
              field: 'accidentDesc',
              title: '突发说明',
              width: 80
            }, {
              field: 'note',
              title: '备注',
              width: 80
            }, {
              field: 'surgeryExePrice',
              hide: true
            }, {
              toolbar: "#row-bar",
              title: '操作',
              width: 260
            }
          ]
        ]
      })
      /* 监听头部工具栏时间 */
      table.on("toolbar(bookingsTable)", function (obj) {
        switch (obj.event) {
          case "addBooking":
            layer.msg("添加")
            openAdd()
            break;
          case "batchDelete":
            layer.msg("批量删除")
            batchDelete()
            break;
        }
      })
      // 添加或者修改的url
      var addOrEditUrl;
      // 弹出层的索引
      var mainIndex;
      /* 打开添加页面 */
      function openAdd() {
        mainIndex = layer.open({
          type: 1,
          title: '添加执行信息',
          maxmin: true,
          content: $("#addOrEditDiv"),
          area: ['800px'],
          success: function (index) {
            $("#dataForm")[0].reset();
            addOrEditUrl = "/surgeryexe/add";
          }
        });
      }
      /* 批量删除 */
      function batchDelete() {

      }

      // 行中工具条事件
      table.on('tool(bookingsTable)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）

        if (layEvent === 'del') { //删除
          layer.confirm('真的删除行么', function (index) {
            obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
            layer.close(index);
            //向服务端发送删除指令
            openDelete(data);
          });
        } else if (layEvent === 'edit') { //编辑

          openEdit(data);
        } else if (layEvent === "emparr") {
          // 人员安排
          openEmpArr(data);
        }
      });
      /* 删除，更改为过期的信息  */
      function openDelete(data) {
        $.ajax({
          url: addOrEditUrl,
          contentType: 'application/json;charset=utf-8',
          type: "post",
          data: JSON.stringify(data.field),
          success: function (res) {
            layer.msg("success")
          }
        });
      }
      /* 打开修改页面 */
      function openEdit(data) {
        console.log(data)
        mainIndex = layer.open({
          type: 1,
          title: '修改执行信息',
          maxmin: true,
          content: $("#addOrEditDiv"),
          area: ['800px'],
          success: function (index) {
            form.val("dataForm", data);
            addOrEditUrl = "/surgeryexe/update";
          }
        });
      }
      // 打开人员安排页面
      function openEmpArr(data) {
        layer.open({
          type: 1,
          title: '人员安排信息',
          maxmin: true,
          content: $("#empArrDiv"),
          area: ['800px', '800px'],
          success: function (index) {
            $("#surgeryExeIdForArr").text(data.surgeryExeId)
            // 请求所有的员工信息
            $.post("/findEmps", null, function (data) {
              // 人员模板渲染
              var getTpl = emps.innerHTML,
                view = document.getElementById('shuttle_box_left');
              laytpl(getTpl).render(data, function (html) {
                view.innerHTML = html;
              });
            })
            // 请求角色的信息
            $.ajax({
              url: "/surgeryrole/all",
              contentType: 'application/json;charset=utf-8',
              type: "post",
              data: JSON.stringify({}),
              success: function (data) {
                // 手术角色模板渲染
                var getTpl = rolesSelect.innerHTML,
                  view = document.getElementById('surgeryRole');
                laytpl(getTpl).render(data, function (html) {
                  view.innerHTML = html;

                })
              }
            });
            // 获取已有的人员安排信息
            $.post("/surgeryemparr/get?surgeryExeId="+data.surgeryExeId,null,function(data){
              // 模板渲染
              console.log(data)
              var getTpl = surgeryArrs.innerHTML,
                  view = document.getElementById('shuttle_box_right');
                laytpl(getTpl).render(data, function (html) {
                  view.innerHTML = html;

                })
              
            })
          }
        })
      }
      //穿梭框左侧选中
      $("#shuttle_box_left").on('click', 'li', function () {
        if ($(this).hasClass('shuttle_box_li_act')) {
          $(this).removeClass('shuttle_box_li_act');
        } else {
          $(this).addClass('shuttle_box_li_act');
        }
      });
      //穿梭框右侧选中
      $("#shuttle_box_right").on('click', 'li', function () {
        if ($(this).hasClass('shuttle_box_li_act')) {
          $(this).removeClass('shuttle_box_li_act');
        } else {
          $(this).addClass('shuttle_box_li_act');
        }
      });
      //穿梭框向右移动
      $("#shuttle_box_toRight").click(function () {
        if ($("#shuttle_box_left .shuttle_box_li_act").length == 0) return false;
        if ($("#surgeryRole").val() != "") {
          $("#shuttle_box_left").find('.shuttle_box_li_act')
            .append("<span data-role='" + $("#surgeryRole").val() + "'>" + "&nbsp;&nbsp;|&nbsp;&nbsp;" +
              $(
                "#surgeryRole").find("option:selected").text() + "</span>")

          $("#shuttle_box_left").find('.shuttle_box_li_act').appendTo("#shuttle_box_right");
          $("#shuttle_box_right li").removeClass('shuttle_box_li_act');
        } else {
          alert("请选择")
        }
      });
      //穿梭框向左移动
      $("#shuttle_box_toLeft").click(function () {
        if ($("#shuttle_box_right .shuttle_box_li_act").length == 0) return false;

        $("#shuttle_box_right .shuttle_box_li_act").find("span[data-role]").remove()
        $("#shuttle_box_right .shuttle_box_li_act").appendTo("#shuttle_box_left");
        $("#shuttle_box_left li").removeClass('shuttle_box_li_act');
      });
      // 中间角色的selectchange事件
      $("#surgeryRole").change(function () {
        var checkText = $("#surgeryRole").find("option:selected").text();
        console.log(checkText)
      })
      // 获取所有的人员安排
      $("#surgeryArrSubmit").click(function () {
        var param = [];
        if ($("#shuttle_box_right li").length == 0) {
          alert("请选择人员安排")
        } else {

          $("#shuttle_box_right li").each(function (index, ele) {
            var item = {}
            console.log(index);
            console.log(ele);
            console.log(ele.children)
            console.log($(ele).find("span[data-empid]").attr("data-empid"))
            item.arrId = $(ele).find("span[data-empid]").attr("data-arrId")
            item.empId = $(ele).find("span[data-empid]").attr("data-empid")
            item.surgeryRoleId = $(ele).find("span[data-role]").attr("data-role")
            item.surgeryExeId = $("#surgeryExeIdForArr").text()
            console.log(item)
            param.push(item)
          });
          console.log(param);
          var requestJson = {};
          requestJson.data = param;
          // 发送请求
          $.ajax({
            url: "/surgeryemparr/add",
            contentType: 'application/json;charset=utf-8',
            type: "post",
            data: JSON.stringify(requestJson),
            success: function (res) {
              layer.msg(res)

            }
          });
        }
      })

      //触发弹出层的更新或者添加按钮
      form.on("submit(doSubmit)", function (data) {
        console.log("----添加或更新", data)
        $.ajax({
          url: addOrEditUrl,
          contentType: 'application/json;charset=utf-8',
          type: "post",
          data: JSON.stringify(data.field),
          success: function (res) {
            layer.msg("success")
            console.log(data)
            //关闭弹出层
            layer.close(mainIndex);
            tableIns.reload()
          }
        });
        return false;
      });

      // 条件查询
      form.on('submit(search)', function (data) {
        //alert(data.data)
        console.log(data.field)
        // 表格数据重载
        tableIns.reload({
          where: data.field,
          page:1
        })
        return false;
      })

    })
  </script>
</body>

</html>